<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    var socket;
    if ("WebSocket" in window) {
        var ws = new WebSocket("ws://103.231.15.234:52347");
        socket = ws;
        ws.onopen = function () {
            console.log('连接成功');
        };
        ws.onmessage = function (evt) {
            var received_msg = evt.data;
            document.getElementById("showMes").value += evt.data + "\n";
        };
        ws.onclose = function () {
            alert("断开了连接");
        };
    } else {
        alert("浏览器不支持WebSocket");
    }

    function login() {
        var message = document.getElementById("mes").value;
        socket.send(message);
    }
</script>
<body>
<textarea rows="3" cols="30" id="showMes" style="width:300px;height:500px;"></textarea>
<br/>
<label>消息</label>
<input type="text" id="mes"/>
<button onclick="login();">发送</button>
<div>
    <header>测试建立会话的消息</header>
    <div>
        {"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoi5Luj5LujIiwiaWQiOjIxLCJwaG9uZSI6IjE3MzgxNTg4ODE0IiwibGF0IjoxNTgyMDAwNTQ0LCJleHAiOjE1ODI4NjQ1NDQsInVzZXJfdHlwZSI6MX0.HG7mNJ8CZ7BnAS_dmElI9ARysHM0aKdGPe3gT8wRXnk","type":1,"msg_code":201}
    </div>
</div>
</body>
</html>